import axios from './axios';
import md5 from 'md5';

/**
 * 获取用户信息
 */
export const getUserDetail = (id) => {
    let obj = {}
    if (id) obj = {data: {id}}; 
    return axios.post('user/userDetail', obj)
}

/**
 * 用户关注
 * @param {*} 关注的作者id 
 */
export const focus = (id) => {
    return axios.post('user/focus', { data: { id } })
}

/**
 * 用户取消关注
 * @param {*} 取消关注的作者id 
 */
export const unfocus = (id) => {
    return axios.post('user/unfocus', { data: { id } })
}


/**
 * 获取用户关注的所有用户
 */

export const getUserFocus = (id) => {
    return axios.post('user/focusUsers', {data: {id}});
}

/**
 * 修改用户名
 * @param {*} username 
 */
export const changeUsername = (username) => {
    return axios.post('user/changeUsername', {data: {username}})
}

/**
 * 修改职位名
 * @param {*} jobName 
 */
export const changeJobName = (jobName) => {
    return axios.post('user/changeJobName', {data: {jobName}})
}


/**
 * 修改公司名
 * @param {*} companyName 
 */
export const changeCompanyName = (companyName) => {
    return axios.post('user/changeCompanyName', {data: {companyName}})
}


/**
 * 修改密码
 * @param {*} passwrod 原密码 
 * @param {*} repassword 要修改的密码 
 */
export const changePass = (password, repassword) => {
    return axios.post('user/changePass', {data: {password: md5(password), repassword: md5(repassword)}})
}